﻿namespace MS.BasicData.Infrastructure
{
    public class ApiResult 
    {


        public bool IsSuc { get; set; }
        public StatuCode Code { get; set; }

        public string Message { get; set; }

        public object? Data { get; set; }


        public ApiResult(bool isSuc, StatuCode code, string message, object? data)
        {
            IsSuc = isSuc;
            Code = code;
            Message = message;
            Data = data;
        }

        //返回成功的结果
        public static ApiResult Success(string message = "操作成功", object? data = null)
        {
            return new ApiResult(true, StatuCode.Ok, message, data);
        }

        //返回失败的结果
        public static ApiResult Fail(string message="操作失败")
        {
            return new ApiResult(false, StatuCode.Fail, message, null);
        }

    }

    public enum StatuCode
    {
        Ok = 200,
        Fail = 500
    }
}
